<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>generator函数</title>
  <script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.5.0/jquery.min.js"></script>
  <script>
    function getData() {
      return $.ajax({
        url: 'http://47.94.46.113:7788/user/login',
        method: 'POST',
        data: JSON.stringify({
          username: 'admin1',
          password: '123321'
        }),
        contentType: 'application/json',
        success: function(res) {
          geo.next(res)
        }
      })
    }

    function* findAll() {
      let res =  yield getData()
      console.log(res);
      yield 2
    }
    let geo = findAll();
    geo.next();
  </script>
</head>
<body>
  
</body>
</html>